<?php

namespace App\Models;

use App\Models\Traits\BaseModels;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\MessageTemplate
 *
 * @property int $id
 * @property string $desc 说明
 * @property string|null $title 消息标题
 * @property string $content 消息内容
 * @property string|null $key_word 关键字
 * @property string $url 超链接
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereDesc($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereKeyWord($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageTemplate whereUrl($value)
 * @mixin \Eloquent
 */
class MessageTemplate extends Model
{
    use BaseModels;

    protected $fillable = [
        'type',
        'desc',
        'title',
        'content',
        'key_word',
        'url',
        'status'
    ];

    /**
     * Description:url获取器
     * Author: Sam
     * DateTime: 2019-01-31 09:53
     * @param $value
     * @return string
     */
    public function getUrlAttribute($value)
    {
        return trim($value);
    }
    
    /**
     * 页面类消息
     */
    const TYPE_PAGE = 1;

    /**
     * 自定义消息
     */
    const TYPE_MSG = 2;

    /**
     * 页面消息模板启用
     */
    const STATUS_ON = 1;

    /**
     * 页面消息模板不启用
     */
    const STATUS_OFF = 0;
}
